package com.gdk.controller;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gdk.service.FairService;
import com.gdk.service.HotelService;
import com.gdk.service.UserService;
import com.gdk.utils.HUtil;
import com.gdk.utils.MapTypeAdapter;
import com.gdk.utils.XVDateUtils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;


/**
 * controller
 * */

@Controller
public class TestController {
	@Autowired
	UserService userService;
	@Autowired
	HotelService hotelService;
	@Autowired
    private FairService fairService;
	
	 /**
	  *  Excel导入
	  *  @author xuwei
	 * @throws Exception 
	  * */
	 @ResponseBody
	 @RequestMapping("/getExcelData.do")  
	 public Map<String,Object> getExcelData(@RequestParam Map<String,Object> map,HttpServletRequest request)  {
			
		 	Map<String,Object> result_map = new HashMap<String,Object>();
		 	
			result_map.put("result_status", 0);
		 	try {
				String file_address = map.get("file_address").toString();
				
				System.out.println("file_address  : "+file_address);
				if(!file_address.contains(".")) {
					result_map.put("result_status", -3);
					return result_map;
				}
				
				int indexOf = file_address.lastIndexOf(".");
				
				System.out.println("indexOf :"+indexOf);
				System.out.println("file_address.length() :"+file_address.length());
				
				if(indexOf+1 == file_address.length()) {
					result_map.put("result_status", -4);
					return result_map;
				}
				
				
				String file_type = file_address.substring(indexOf+1, file_address.length());
				System.out.println("file_type : "+file_type);
				
				if(!file_type.equals("xlsx")) {
					result_map.put("result_status", -5);
					return result_map;
				}
				
				//本地文件
				//XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File(file_address)));
				//远程文件
				URL url = new URL(file_address);//把远程文件地址转换成URL格式
	            InputStream fin = url.openStream();
	            XSSFWorkbook workbook = new XSSFWorkbook(fin);
				
	            
	            
	            
				 XSSFSheet sheet = null;
		        System.out.println("表数量 :  "+ workbook.getNumberOfSheets());
		        for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
		            sheet = workbook.getSheetAt(i);
		            System.out.println("表 : "+i+1+"  数据行 :  "+ sheet.getPhysicalNumberOfRows());
		            for (int j = 0; j < sheet.getPhysicalNumberOfRows(); j++) {
		            	System.out.println("行数   :  "+(j+1));
		                XSSFRow row = sheet.getRow(j);
		                //System.out.println("row  : "+row.getLastCellNum());
		                //row.getLastCellNum()  代表有几列数据
		                for (int k = 0; k < row.getLastCellNum(); k++) {
		                	System.out.println(row.getCell(k));
		                	
		                    //System.out.print(row.getCell(k) + "\t");
		                }
		                System.out.println();
		            }
		        }
			} catch (FileNotFoundException e) {
				e.printStackTrace();
				System.out.println("文件路径错误");
				result_map.put("result_status", -1);
				return result_map;
			} catch (IOException e) {
				e.printStackTrace();
				System.out.println("IO错误");
				result_map.put("result_status", -2);
				return result_map;
			}
	       
			return result_map;
	 }
	 
	 
	 /**
	  *  Excel导入
	  *  @author xuwei
	 * @throws Exception 
	  * */
	 @ResponseBody
	 @RequestMapping("/verifyImportExcelData.do")  
	 public Map<String,Object> verifyImportExcelData(@RequestParam Map<String,Object> map,HttpServletRequest request)  {
			
		 Map<String,Object> result_map = new HashMap<String,Object>();
		 	
			result_map.put("result_status", 0);
		 	try {
				//String file_address = "C:/Users/91578/Desktop/user_template.xlsx";
		 		String file_address = map.get("file_address").toString();
				System.out.println("file_address  : "+file_address);
				if(!file_address.contains(".")) {
					result_map.put("result_status", -3);
					
				}
				
				int indexOf = file_address.lastIndexOf(".");
				
				System.out.println("indexOf :"+indexOf);
				System.out.println("file_address.length() :"+file_address.length());
				
				if(indexOf+1 == file_address.length()) {
					result_map.put("result_status", -4);
				}
				
				
				String file_type = file_address.substring(indexOf+1, file_address.length());
				System.out.println("file_type : "+file_type);
				
				if(!file_type.equals("xlsx")) {
					result_map.put("result_status", -5);
				}
				
				//本地文件
				//XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File(file_address)));
				//远程文件
				URL url = new URL(file_address);//把远程文件地址转换成URL格式
	            InputStream fin = url.openStream();
	            XSSFWorkbook workbook = new XSSFWorkbook(fin);
				
	            
				 XSSFSheet sheet = null;
				 
				 List<Map<String,Object>> excelList = new ArrayList<Map<String,Object>>();
				 
				 
				 List<Map<String,Object>> errList = new ArrayList<Map<String,Object>>();
				 
		        System.out.println("表数量 :  "+ workbook.getNumberOfSheets());
		        //表
		        for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
		        	
		            sheet = workbook.getSheetAt(i);
		            System.out.println("表 : "+i+1+"  数据行 :  "+ sheet.getPhysicalNumberOfRows());
		            int flag = 0;
		            //行
		            for (int j = 0; j < sheet.getPhysicalNumberOfRows(); j++) {
		            	Map<String,Object> rowMap = new HashMap<String,Object>();
		            	if(flag == 1) {return result_map;}
		            	System.out.println("行数   :  "+(j+1));
		                XSSFRow row = sheet.getRow(j);
		                
		                if(row != null) {
		                	System.out.println("row  : "+row.getLastCellNum());
		                	
		                	//判断第一行每列是否有数据
		                	if((j+1) == 1) {
		                		System.out.println("11 : "+row.getCell(0) + "  "+row.getCell(1) +"   "+row.getCell(2) +"   "+row.getCell(3)+"   "+row.getCell(4)+"   "+row.getCell(5) );
		                		if(row.getCell(0) == null || "".equals(row.getCell(0)) || row.getCell(1) == null || "".equals(row.getCell(1)) || row.getCell(2) == null || "".equals(row.getCell(2))  || row.getCell(3) == null || "".equals(row.getCell(3)) || row.getCell(4) == null || "".equals(row.getCell(4))  || row.getCell(5) == null || "".equals(row.getCell(5)) || row.getCell(6) == null || "".equals(row.getCell(6))) {
		                			System.out.println("文件内容错误");
		                			result_map.put("result_status", -6);
		                			flag = 1;
		                			return result_map;
		                		}
		                	}
		                	
		                	//row.getLastCellNum()  代表有几列数据
		                	//列
		                	for (int k = 0; k < row.getLastCellNum(); k++) {
		                		//判断第一行每列是否符合模板数据
		                		if((j+1) == 1) {
		                			if(!row.getCell(0).toString().trim().equals("姓名")) {
		                				System.out.println("文件内容错误 : "+row.getCell(0));
		                				result_map.put("result_status", -7);
		                				flag = 1;
		                				return result_map;
		                			}
		                			if(!row.getCell(1).toString().trim().equals("手机号")) {
		                				System.out.println("文件内容错误 : "+row.getCell(1));
		                				result_map.put("result_status", -7);
		                				flag = 1;
		                				return result_map;
		                			}
		                			if(!row.getCell(2).toString().trim().equals("所属单位")) {
		                				System.out.println("文件内容错误 : "+row.getCell(2));
		                				result_map.put("result_status", -7);
		                				flag = 1;
		                				return result_map;
		                			}
		                			if(!row.getCell(3).toString().trim().equals("会议及座次")) {
		                				System.out.println("文件内容错误 : "+row.getCell(3));
		                				result_map.put("result_status", -7);
		                				flag = 1;
		                				return result_map;
		                			}
		                			if(!row.getCell(4).toString().trim().equals("性别")) {
		                				System.out.println("文件内容错误 : "+row.getCell(4));
		                				result_map.put("result_status", -7);
		                				flag = 1;
		                				return result_map;
		                			}
		                			if(!row.getCell(5).toString().trim().equals("类型")) {
		                				System.out.println("文件内容错误 : "+row.getCell(5));
		                				result_map.put("result_status", -7);
		                				flag = 1;
		                				return result_map;
		                			}
		                			if(!row.getCell(6).toString().trim().equals("地区")) {
		                				System.out.println("文件内容错误 : "+row.getCell(6));
		                				result_map.put("result_status", -7);
		                				flag = 1;
		                				return result_map;
		                			}
		                			
		                		}
		                		//打印每一列的数据
		                		//System.out.println(row.getCell(k));
		                		DecimalFormat df = new DecimalFormat("#.#");
		                		//System.out.println(df.format(a));
		                		if((j+1) > 1) {
		                			//获取每一列数据
		                			if(row.getCell(k) != null && !"".equals(row.getCell(k).toString().trim())) {
		                				if(row.getCell(0) != null && !"".equals(row.getCell(0).toString().trim())) {
		                					if(!row.getCell(0).toString().trim().equals("null")) {
		                						String u_name = row.getCell(0).toString().trim();
		                						rowMap.put("u_name", u_name);
		                						
		                						if(row.getCell(1) != null) {
		                							if(!row.getCell(1).toString().trim().equals("null")) {
		                								String u_phone = row.getCell(1).toString().trim();
		                								
		                								if(u_phone.contains(".0")) {
		                									int f = u_phone.lastIndexOf(".0");
		                									u_phone = u_phone.substring(0,f);
		                								}
		                								
		                								
		                								rowMap.put("u_phone", u_phone);
		                							}
		                						}
		                						if(row.getCell(2) != null) {
		                							if(!row.getCell(2).toString().trim().equals("null")) {
		                								String u_idc = row.getCell(2).toString().trim();
		                								if(u_idc.contains(".0")) {
		                									int f = u_idc.lastIndexOf(".0");
		                									u_idc = u_idc.substring(0,f);
		                								}
		                								rowMap.put("u_idc", u_idc.toString());
		                							}
		                						}
		                						if(row.getCell(3) != null) {
		                							if(!row.getCell(3).toString().trim().equals("null")) {
		                								String u_zc = row.getCell(3).toString().trim();
		                								System.out.println("u_zc : "+u_zc);
		                								if(u_zc.contains(".0")) {
		                									int f = u_zc.lastIndexOf(".0");
		                									u_zc = u_zc.substring(0,f);
		                								}
		                								/*	String[] zc_arr = u_zc.split(",,,");
					                				for (String zc : zc_arr) {
														System.out.println("zc : "+zc);
													}*/
		                								rowMap.put("u_zc", u_zc);
		                							}
		                						}
		                						if(row.getCell(4) != null) {
		                							if(!row.getCell(4).toString().trim().equals("null")) {
		                								String p_sex = row.getCell(4).toString().trim();
		                								if(p_sex.equals("女")) {
		                									rowMap.put("u_sex", 2);
		                								}else {
		                									rowMap.put("u_sex", 1);
		                								}
		                							}
		                						}else {
		                							rowMap.put("u_sex", 1);
		                						}
		                						if(row.getCell(5) != null) {
		                							if(!row.getCell(5).toString().trim().equals("null")) {
		                								String p_sex = row.getCell(5).toString().trim();
		                								if(p_sex.equals("销售")) {
		                									rowMap.put("u_type", 2);
		                								}else {
		                									rowMap.put("u_type", 1);
		                								}
		                							}
		                						}else {
		                							rowMap.put("u_type", 1);
		                						}
		                						if(row.getCell(6) != null) {
		                							if(!row.getCell(6).toString().trim().equals("null")) {
		                								String u_address = row.getCell(6).toString().trim();
		                								
		                								rowMap.put("u_address", u_address);
		                							}
		                						}
		                					}
		                				}
		                			}
		                			
		                		}
		                		
		                	}
		                	System.out.println("rowMap : "+rowMap);
		                	//不为空
		                	if(!rowMap.isEmpty()) {
		                		excelList.add(rowMap);	                	
		                	}
		                }
		                
		                
		              //  System.out.println();
		            }
		            
	                //System.out.print(row.getCell(k) + "\t");
		        }
		        //成功次数
                int success = 0;
                //失败次数
                int defeat = 0;
                
                
                //执行新增用户
                if(excelList.size() > 0) {
                	//查询出所有会议
                	List<Map<String, Object>> allFair = fairService.findAllFair(map);
                	//新增用户
                	for (Map<String,Object> userMap: excelList) {
                		userMap.put("addtime", XVDateUtils.getCurrenTimeMillis());
						System.out.println("userMap : "+userMap);
						//使用手机号查询用户是否存在
						
						List<Map<String, Object>> userDetailsByPhone = userService.selectUserDetailsByPhone(HUtil.putInMap("u_phone",userMap.get("u_phone")));
						if(userDetailsByPhone.size() == 0) {
							 int k = userService.addUser(userMap);
							 if(k == 1) {
								 String[] zc_arr = userMap.get("u_zc").toString().split(",,,");
				    				for (String zc : zc_arr) {
										System.out.println("zc : "+zc);
										if(zc.contains("[")) {
											String f_title = zc.substring(0,zc.indexOf("["));
											//System.out.println("f_title : "+f_title);
											String si_zc = zc.substring(zc.lastIndexOf("[")+1,zc.lastIndexOf("]"));
										//	System.out.println("si_zc : "+si_zc);
											//新增会议和用户绑定
											//查询 f_title 是否存在
											for (Map<String, Object> map3 : allFair) {
												String data_f_title = map3.get("f_title").toString().trim();
												if(f_title.trim().equals(data_f_title)) {
													//绑定用户和会议
													int u_id = Integer.valueOf(userMap.get("u_id").toString());
													Map<String,Object> bindMap = new HashMap<String,Object>();
													bindMap.put("u_id", u_id);
													bindMap.put("f_id", map3.get("f_id"));
													bindMap.put("si_zc", si_zc);
													fairService.bindUserAndFair(bindMap);
												}
											}
											
										}
									}
								 success = success +1;
							 }else {
								 defeat = defeat+1;
								 userMap.put("errMsg","插入失败");
									/*
									 * Map<String,Object> errMap = new HashMap<>();
									 * errMap.put("姓名",userMap.get("u_name"));
									 * errMap.put("手机号",userMap.get("u_phone"));
									 * errMap.put("参会信息",userMap.get("u_zc")); errMap.put("失败原因","插入失败");
									 */
								 errList.add(userMap);
							 }
							
						}else {
							 defeat = defeat+1;
							 userMap.put("errMsg","手机号重复,无法插入");
							 errList.add(userMap);
						}
						
					}
                	
                }
                
                if(success > 0) {
                	result_map.put("success", success);
                	result_map.put("defeat", defeat);
                	
                	result_map.put("errInfo", errList.toString());
                	result_map.put("result_status", 1);
                }else {
                	result_map.put("success", success);
                	result_map.put("defeat", defeat);
                	result_map.put("errInfo", errList.toString());
                	result_map.put("result_status", 0);
                }
                
                
		        System.out.println("excelList : "+excelList);
			} catch (FileNotFoundException e) {
				e.printStackTrace();
				System.out.println("文件路径错误");
				result_map.put("result_status", -1);
			} catch (IOException e) {
				e.printStackTrace();
				System.out.println("IO错误");
				result_map.put("result_status", -2);
			}
			 
		 	 System.out.println("result_map : "+result_map);
		 	 return result_map;
	 }
	 
	 
	 
	 
	 /**
	  *  Excel导入酒店房间
	  *  @author xuwei
	 * @throws Exception 
	  * */
	 @ResponseBody
	 @RequestMapping("/verifyImportExcelHotelData.do")  
	 public Map<String,Object> verifyImportExcelHotelData(@RequestParam Map<String,Object> map,HttpServletRequest request)  {
			
		 Map<String,Object> result_map = new HashMap<String,Object>();
		 	
			result_map.put("result_status", 0);
		 	try {
				//String file_address = "C:/Users/91578/Desktop/user_template.xlsx";
		 		String file_address = map.get("file_address").toString();
				System.out.println("file_address  : "+file_address);
				if(!file_address.contains(".")) {
					result_map.put("result_status", -3);
					
				}
				
				int indexOf = file_address.lastIndexOf(".");
				
				System.out.println("indexOf :"+indexOf);
				System.out.println("file_address.length() :"+file_address.length());
				
				if(indexOf+1 == file_address.length()) {
					result_map.put("result_status", -4);
				}
				
				
				String file_type = file_address.substring(indexOf+1, file_address.length());
				System.out.println("file_type : "+file_type);
				
				if(!file_type.equals("xlsx")) {
					result_map.put("result_status", -5);
				}
				
				//本地文件
				//XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File(file_address)));
				//远程文件
				URL url = new URL(file_address);//把远程文件地址转换成URL格式
	            InputStream fin = url.openStream();
	            XSSFWorkbook workbook = new XSSFWorkbook(fin);
				
	            
				 XSSFSheet sheet = null;
				 
				 List<Map<String,Object>> excelList = new ArrayList<Map<String,Object>>();
				 
		        System.out.println("表数量 :  "+ workbook.getNumberOfSheets());
		        //表
		        for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
		        	
		            sheet = workbook.getSheetAt(i);
		            System.out.println("表 : "+i+1+"  数据行 :  "+ sheet.getPhysicalNumberOfRows());
		            int flag = 0;
		            //行
		            for (int j = 0; j < sheet.getPhysicalNumberOfRows(); j++) {
		            	Map<String,Object> rowMap = new HashMap<String,Object>();
		            	if(flag == 1) {return result_map;}
		            	System.out.println("行数   :  "+(j+1));
		                XSSFRow row = sheet.getRow(j);
		                System.out.println("row  : "+row.getLastCellNum());
		                
		                //判断第一行每列是否有数据
		                if((j+1) == 1) {
		            		System.out.println("11 : "+row.getCell(0) + "  "+row.getCell(1) +"   ");
		            		if(row.getCell(0) == null || "".equals(row.getCell(0)) || row.getCell(1) == null || "".equals(row.getCell(1)) ) {//|| row.getCell(2) == null || "".equals(row.getCell(2))  || row.getCell(3) == null || "".equals(row.getCell(3))
		            			System.out.println("文件内容错误");
		        				result_map.put("result_status", -6);
		        				flag = 1;
		        				return result_map;
		            		}
	            		}
		                
		                //row.getLastCellNum()  代表有几列数据
		                //列
		                for (int k = 0; k < row.getLastCellNum(); k++) {
		                	//判断第一行每列是否符合模板数据
		                	if((j+1) == 1) {
		                		if(!row.getCell(0).toString().trim().equals("酒店")) {
		                			System.out.println("文件内容错误 : "+row.getCell(0));
		            				result_map.put("result_status", -7);
		            				flag = 1;
		            				return result_map;
		                		}
		                		if(!row.getCell(1).toString().trim().equals("房间号")) {
		                			System.out.println("文件内容错误 : "+row.getCell(1));
		            				result_map.put("result_status", -7);
		            				flag = 1;
		            				return result_map;
		                		}
		                	/*	if(!row.getCell(2).toString().trim().equals("性别")) {
		                			System.out.println("文件内容错误 : "+row.getCell(2));
		            				result_map.put("result_status", -7);
		            				flag = 1;
		            				return result_map;
		                		}
		                		if(!row.getCell(3).toString().trim().equals("类型")) {
		                			System.out.println("文件内容错误 : "+row.getCell(3));
		            				result_map.put("result_status", -7);
		            				flag = 1;
		            				return result_map;
		                		}*/
		                	}
		                	//打印每一列的数据
		                	//System.out.println(row.getCell(k));
		                	DecimalFormat df = new DecimalFormat("#.#");
		                	//System.out.println(df.format(a));
		                	if((j+1) > 1) {
		                		//获取每一列数据
		                		if(row.getCell(k) != null && !"".equals(row.getCell(k).toString().trim())) {
		                			if(row.getCell(0) != null && !"".equals(row.getCell(0).toString().trim())) {
			                			if(!row.getCell(0).toString().trim().equals("null")) {
			                				String hrn_name = row.getCell(0).toString().trim();
			                				rowMap.put("hrn_name", hrn_name);
			                				if(row.getCell(1) != null) {
			                					if(!row.getCell(1).toString().trim().equals("null")) {
					                				String hr_room = row.getCell(1).toString().trim();
					                				if(hr_room.contains(".0")) {
					                					int f = hr_room.lastIndexOf(".0");
					                					hr_room = hr_room.substring(0,f);
					                				}
					                				rowMap.put("hr_room", hr_room);
					                			}
			                				}
			                				
			                			/*	if(row.getCell(2) != null) {
				                				if(!row.getCell(2).toString().trim().equals("null")) {
					                				String hr_sex = row.getCell(2).toString().trim();
					                				if(hr_sex.equals("女")) {
					                					rowMap.put("hr_sex", 2);
					                				}else {
					                					rowMap.put("hr_sex", 1);
					                				}
					                			}
			                				}else {
			                					rowMap.put("hr_sex", 1);
			                				}
			                				if(row.getCell(3) != null) {
				                				if(!row.getCell(3).toString().trim().equals("null")) {
					                				String hr_type = row.getCell(3).toString().trim();
					                				if(hr_type.equals("销售")) {
					                					rowMap.put("hr_type", 2);
					                				}else {
					                					rowMap.put("hr_type", 1);
					                				}
					                			}
			                				}else {
			                					rowMap.put("hr_type", 1);
			                				}*/
			                			}
		                			}
		                		}
		                		
		                	}
		                	
		                }
		                System.out.println("rowMap : "+rowMap);
		                //不为空
		                if(!rowMap.isEmpty()) {
		                	excelList.add(rowMap);	                	
		                }
		              //  System.out.println();
		            }
		            
	                //System.out.print(row.getCell(k) + "\t");
		        }
		        //成功次数
                int success = 0;
                //失败次数
                int defeat = 0;
                
                
                //执行新增房间
                if(excelList.size() > 0) {
                	//查询出所有酒店
                	List<Map<String, Object>> allHotel = hotelService.selectAllHotel(map);
                	if(allHotel.size() == 0) {
                		System.out.println("无可选酒店");
        				result_map.put("result_status", -8);
                	}else {
                		//新增房间
                    	for (Map<String,Object> hotelMap: excelList) {
                    		hotelMap.put("hr_addtime", XVDateUtils.getCurrenTimeMillis());
                    		
                    		for (Map<String, Object> map2 : allHotel) {
								String hrn_name = map2.get("hrn_name").toString();
								String p_hrn_name = hotelMap.get("hrn_name").toString();
                    		
								if (hrn_name.equals(p_hrn_name)) {
									hotelMap.put("hrn_id", map2.get("hrn_id"));
									System.out.println("hotelMap : "+hotelMap);
									
									int k = hotelService.addHotelRoom(hotelMap);
		    						if(k == 1) {
		    							success = success +1;
		    							//新增床位
		    							int hr_id = Integer.valueOf(hotelMap.get("hr_id").toString());
		    							
		    							//创建床位
		    							Map<String,Object> bedMap = new HashMap<String,Object>();
		    							bedMap.put("hb_bed", "01");
		    							bedMap.put("hr_id", hr_id);
		    							bedMap.put("hb_status", 0);
		    							bedMap.put("hb_addtime", XVDateUtils.getCurrenTimeMillis());
		    							
		    							hotelService.addHotelBed(bedMap);
		    							
		    							bedMap.put("hb_bed", "02");
		    							bedMap.put("hr_id", hr_id);
		    							bedMap.put("hb_status", 0);
		    							bedMap.put("hb_addtime", XVDateUtils.getCurrenTimeMillis());
		    							
		    							hotelService.addHotelBed(bedMap);
		    							
		    							
		    						}else {
		    							defeat = defeat+1;
		    						}
								}
                    		}
    						 
    					}
                	}
                	
                	
                }
                
                if(success > 0) {
                	result_map.put("success", success);
                	result_map.put("defeat", defeat);
                	result_map.put("result_status", 1);
                }else {
                	result_map.put("success", success);
                	result_map.put("defeat", defeat);
                	result_map.put("result_status", 0);
                }
                
                
		        System.out.println("excelList : "+excelList);
			} catch (FileNotFoundException e) {
				e.printStackTrace();
				System.out.println("文件路径错误");
				result_map.put("result_status", -1);
			} catch (IOException e) {
				e.printStackTrace();
				System.out.println("IO错误");
				result_map.put("result_status", -2);
			}
			 
		 	 System.out.println("result_map : "+result_map);
		 	 return result_map;
	 }
}